/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Test.java
 *
 * Created on 07 Sep 14, 13:08:48
 */
package com.pras.skripsi.view;

import com.pras.skripsi.ImageFactory;
import com.pras.skripsi.Result;
import java.awt.Cursor;

/**
 *
 * @author Pras
 */
public class TestBentuk extends javax.swing.JPanel {

    /** Creates new form Test */
    private Object[][] hasil = new Object[2][3];
    private MainFrame frame;
    private int plates = 0;

    public TestBentuk(MainFrame frame) {
        this.frame = frame;
        initComponents();
        initPlates();
    }

    void initPlates() {
        labGambar.setIcon(ImageFactory.getBentuk()[plates]);
        option_1.setIcon(ImageFactory.getOption()[plates][0]);
        option_2.setIcon(ImageFactory.getOption()[plates][1]);
        option_3.setIcon(ImageFactory.getOption()[plates][2]);
        option_4.setIcon(ImageFactory.getOption()[plates][3]);
        option_5.setIcon(ImageFactory.getOption()[plates][4]);
        option_6.setIcon(ImageFactory.getOption()[plates][5]);
    }

    private void jawab(int option) {
        try {
            this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            switch (option) {
                case 0:
                    hasil[plates][1] = ImageFactory.getOption()[plates][0];
                    break;
                case 1:
                    hasil[plates][1] = ImageFactory.getOption()[plates][1];
                    break;
                case 2:
                    hasil[plates][1] = ImageFactory.getOption()[plates][2];
                    break;
                case 3:
                    hasil[plates][1] = ImageFactory.getOption()[plates][3];
                    break;
                case 4:
                    hasil[plates][1] = ImageFactory.getOption()[plates][4];
                    break;
                case 5:
                    hasil[plates][1] = ImageFactory.getOption()[plates][5];
                    break;
                default:
                    break;
            }

            if (plates == 0) {
                hasil[plates][0] = 4;
                hasil[plates][2] = 26;
                plates += 1;
                initPlates();
            } else {
                hasil[plates][0] = 5;
                hasil[plates][2] = 27;
                Result.setHasilBentuk(hasil);
                Hasil hasil = new Hasil(frame);
                frame.getMainScrollPane().setViewportView(hasil);
            }
        } finally {
            this.setCursor(Cursor.getDefaultCursor());
        }

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labGambar = new javax.swing.JLabel();
        option_1 = new javax.swing.JLabel();
        option_2 = new javax.swing.JLabel();
        option_3 = new javax.swing.JLabel();
        option_4 = new javax.swing.JLabel();
        option_5 = new javax.swing.JLabel();
        option_6 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();

        labGambar.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labGambar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        option_1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        option_1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        option_1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                option_1MouseClicked(evt);
            }
        });

        option_2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        option_2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        option_2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                option_2MouseClicked(evt);
            }
        });

        option_3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        option_3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        option_3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                option_3MouseClicked(evt);
            }
        });

        option_4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        option_4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        option_4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                option_4MouseClicked(evt);
            }
        });

        option_5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        option_5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        option_5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                option_5MouseClicked(evt);
            }
        });

        option_6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        option_6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        option_6.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                option_6MouseClicked(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel1.setText("Pilih gambar sesuai garis yang terlihat");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labGambar, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(option_3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(option_4, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(option_5, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(option_1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(option_2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(option_6, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(12, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labGambar, javax.swing.GroupLayout.PREFERRED_SIZE, 329, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(option_2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(option_1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(54, 54, 54)
                        .addComponent(jLabel1)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(option_6, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(option_5, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(option_4, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(option_3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

private void option_1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_option_1MouseClicked
    jawab(0);
}//GEN-LAST:event_option_1MouseClicked

private void option_2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_option_2MouseClicked
    jawab(1);
}//GEN-LAST:event_option_2MouseClicked

private void option_3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_option_3MouseClicked
    jawab(2);
}//GEN-LAST:event_option_3MouseClicked

private void option_4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_option_4MouseClicked
    jawab(3);
}//GEN-LAST:event_option_4MouseClicked

private void option_5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_option_5MouseClicked
    jawab(4);
}//GEN-LAST:event_option_5MouseClicked

private void option_6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_option_6MouseClicked
    jawab(5);
}//GEN-LAST:event_option_6MouseClicked
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel labGambar;
    private javax.swing.JLabel option_1;
    private javax.swing.JLabel option_2;
    private javax.swing.JLabel option_3;
    private javax.swing.JLabel option_4;
    private javax.swing.JLabel option_5;
    private javax.swing.JLabel option_6;
    // End of variables declaration//GEN-END:variables
}
